/** This class takes care of the Paddles*/

import java.awt.*;

public class CollisionRectangle {
	
	float CoordinateX = 0f;
    float CoordinateY = 0f;
	int Width = 0;
    int Height = 0;
    
	public void UpdateDMastaGXCollisionRectangle(DMastaGX MasterGX){
		
	 DMastaGX.MasterGX.CollisionDetector.CoordinateX = MasterGX.getX();	
	 DMastaGX.MasterGX.CollisionDetector.CoordinateY = MasterGX.getY();
	 DMastaGX.MasterGX.CollisionDetector.Width =  MasterGX.StandingWidth;
	 DMastaGX.MasterGX.CollisionDetector.Height = MasterGX.StandingHeight;
			
		}
    
	// Updates the size of The Collision Rectangle according to The Player, and if he pressed Left.
	public void UpdateDMastaGXCollisionRectangleAbove(DMastaGX MasterGX){

   	 DMastaGX.MasterGX.CollisionDetectorAbove.CoordinateX = MasterGX.getX() + 5;	
	 DMastaGX.MasterGX.CollisionDetectorAbove.CoordinateY = MasterGX.getY();
	 DMastaGX.MasterGX.CollisionDetectorAbove.Width =  MasterGX.StandingWidth - 10;
	 DMastaGX.MasterGX.CollisionDetectorAbove.Height = 0;
		
	}
	
	public void UpdateDMastaGXCollisionRectangleBelow(DMastaGX MasterGX){
		
	DMastaGX.MasterGX.CollisionDetectorBelow.CoordinateX = MasterGX.getX() + 5;	
	DMastaGX.MasterGX.CollisionDetectorBelow.CoordinateY = MasterGX.getY() + MasterGX.StandingHeight;
	DMastaGX.MasterGX.CollisionDetectorBelow.Width =  MasterGX.StandingWidth - 10;
	DMastaGX.MasterGX.CollisionDetectorBelow.Height = 0;
	
	}
	
	public void UpdateDMastaGXCollisionRectangleLeft(DMastaGX MasterGX){
		
	DMastaGX.MasterGX.CollisionDetectorLeft.CoordinateX = MasterGX.getX();
	DMastaGX.MasterGX.CollisionDetectorLeft.CoordinateY = MasterGX.getY() + 30;
	DMastaGX.MasterGX.CollisionDetectorLeft.Width =  0;
	DMastaGX.MasterGX.CollisionDetectorLeft.Height = DMastaGX.MasterGX.StandingHeight - 60;
	
	}
	
	public void UpdateDMastaGXCollisionRectangleRight(DMastaGX MasterGX){
		
		DMastaGX.MasterGX.CollisionDetectorRight.CoordinateX = MasterGX.getX() + MasterGX.StandingWidth;
		DMastaGX.MasterGX.CollisionDetectorRight.CoordinateY = MasterGX.getY() + 30;
	    DMastaGX.MasterGX.CollisionDetectorRight.Width =  0;
	    DMastaGX.MasterGX.CollisionDetectorRight.Height = MasterGX.StandingHeight - 60;
		
	}
	
	public void UpdateTileCollisionRectangle(float TileXCoordinate, float TileYCoordinate, int TileWidth, int TileHeight){
		
		CoordinateX = TileXCoordinate;
		CoordinateY = TileYCoordinate; 
		Width =  TileWidth;
		Height = TileHeight;
		
	}
	
		// This method checks to see if the Rectangle COllided with another
	   public boolean hasCollidedWith(CollisionRectangle Obstacle){
		   
		   return	(   // If One of these is false then there is a collision 
		   
			    	  // If True = You Are In From The Right
			         (Obstacle.CoordinateX + Obstacle.Width >= CoordinateX ) &&
			         
			         // If True = You Are In From The Left
			         (Obstacle.CoordinateX       <= CoordinateX + Width)     &&
			         
			         // If True = You Are In From Below
			         (Obstacle.CoordinateY + Obstacle.Height >= CoordinateY) &&
			         
			         // If True = You Are In From Above
			         (Obstacle.CoordinateY       <= CoordinateY + Height));
		   
	   }
	
	public void draw(Graphics g, String Text){
		
		g.setColor(Color.RED);
		g.drawRect((int)CoordinateX, (int)CoordinateY, Width, Height);
		
		g.setColor(Color.RED);
		g.drawString(Text, (int)CoordinateX, (int)CoordinateY);
		
	}
	
}
